    var $ts = new Tesla();
	
	seajs.on("error", function(e){
		emit($ts.ERROR, e);
	});
	
	
	/**
	 * 实现浏览器回退功能
	 * @param $ts
	 * @returns
	 */
	(function($ts){
		var stateChanged = false,
			isFirst = true;
		
		window.onpopstate = function(e) {
			var obj = $ts.resolveSearch();
			
			isFirst ? isFirst = false : stateChanged = true;
			
			if (obj.action) {
				$ts.load(obj.action, JSON.parse(obj.param));
			}
		};
		
		$ts.on($ts.AFTER_LOAD, function(obj) {
			if (obj.container.attr("id") != $ts.DEFAULT_CONTAINER_ID) {
				return;
			}
			
			if (stateChanged) {
				if (history.pushState){
					history.pushState(null, "", location.pathname + "?action=" + obj.action + "&param=" + JSON.stringify(obj.param));
				}
			} else {
				stateChanged = false;
			}
		});
	})($ts);
	
	module.exports = $ts;
});